﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class 数据访问控件_动态输出服务器控件 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Linq查询DataContext db = new Linq查询DataContext();
        var dbTableSource = from Tab in db.books
                            orderby Tab.bookid descending
                            select new
                            {
                                名字 = Tab.bookname,
                                简介 = Tab.bookcontent,
                                编号 = Tab.bookid,
                                添加时间 = Tab.adddate
                            };

        DataGrid MyGrid = new DataGrid {  DataSource = dbTableSource};
        MyGrid.DataBind();

        //开始动态输出控件

        System.IO.StringWriter StringW = new System.IO.StringWriter();
        Html32TextWriter Hw = new Html32TextWriter(StringW);
        MyGrid.RenderControl(Hw);
        Div.InnerHtml = StringW.ToString();
    }
}
